package cn.csddxt.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import cn.csddxt.util.MybatisUtile;

public class User implements Serializable {
	private Integer id; // id
	private String userCode; // 用户编码
	private String userName; // 用户名称
	private String userPassword; // 用户密码
	private Integer gender; // 性别
	private Date birthday; // 出生日期
	private String phone; // 电话
	private String address; // 地址
	private Integer userRole; // 用户角色
	private Integer createdBy; // 创建�?
	private Date creationDate; // 创建时间
	private Integer modifyBy; // 更新�?
	private Date modifyDate; // 更新时间
	private String sex;// 性别
	private Integer age;// 年龄
	private String birthdays;// 出生日期转字符串
	private List<Address> addresses;// 地址
	private Role role;// 角色信息

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	public List<Address> getAddresses() {
		return addresses;
	}

	public void setAddresses(List<Address> addresses) {
		this.addresses = addresses;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	private String newPassword;// 新密码
	private String userRoleName; // 用户角色名称

	public String getBirthdays() {
		return birthdays;
	}

	public void setBirthdays(String birthdays) {
		this.birthdays = birthdays;
	}

	public String getNewPassword() {
		return newPassword;
	}

	public void setNewPassword(String newPassword) {
		this.newPassword = newPassword;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public User() {
		// TODO 自动生成的构造函数存根
	}

	public User(String userCode, String userPassword) {
		super();
		this.userCode = userCode;
		this.userPassword = userPassword;
	}

	public String getUserRoleName() {
		return userRoleName;
	}

	public void setUserRoleName(String userRoleName) {
		this.userRoleName = userRoleName;
	}

	public Integer getAge() {
		/*
		 * long time = System.currentTimeMillis()-birthday.getTime(); Integer
		 * age = Long.valueOf(time/365/24/60/60/1000).IntegerValue();
		 */
		Date date = new Date();
		if (birthday != null) {
			Integer age = date.getYear() - birthday.getYear();
		}
		return age;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getUserCode() {
		return userCode;
	}

	public void setUserCode(String userCode) {
		this.userCode = userCode;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getUserPassword() {
		return userPassword;
	}

	public void setUserPassword(String userPassword) {
		this.userPassword = userPassword;
	}

	public Integer getGender() {
		return gender;
	}

	public void setGender(Integer gender) {
		if (gender > 1) {
			this.sex = "男";
		} else {
			this.sex = "女";
		}
		this.gender = gender;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		if (birthday != null) {
			this.birthdays = MybatisUtile.datestring(birthday);// 出生日期查询出来转换为字符串
		}
		this.birthday = birthday;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Integer getUserRole() {
		return userRole;
	}

	public void setUserRole(Integer userRole) {
		this.userRole = userRole;
	}

	public Integer getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(Integer createdBy) {
		this.createdBy = createdBy;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	public Integer getModifyBy() {
		return modifyBy;
	}

	public void setModifyBy(Integer modifyBy) {
		this.modifyBy = modifyBy;
	}

	public Date getModifyDate() {
		return modifyDate;
	}

	public void setModifyDate(Date modifyDate) {
		this.modifyDate = modifyDate;
	}
}
